package com.tiamo.traders.controller.controllerFont;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.tiamo.traders.entity.News;
import com.tiamo.traders.servicefront.FrontNewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class FrontNewsController{
    @Autowired
    FrontNewsService frontNewsService;

    @RequestMapping("/news")
    public PageInfo<News> newsFindAll(News news, @RequestParam String type) {
        news.setNewsType(type);
        PageHelper.startPage(news.getPageNo(),news.getPageSize());
        PageInfo<News> pageInfo=new PageInfo<>(frontNewsService.newsFindAll(news));
        return pageInfo;
    }

    @RequestMapping("/newsGetCount")
    public int newsGetCount(News news) {
        return frontNewsService.newsGetCount(news);
    }

    @RequestMapping("/newsFindById")
    public List<News> newsFindById(News news) {
        return frontNewsService.newsFindById(news);
    }
}
